package com.example.demo.Dao;

import com.example.demo.model.BookInfo;
import com.example.demo.model.ListInfoMoke;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookInfoDao {

    @Select("select* from book_info where status!=0 order by id desc limit #{ currentPage},#{pageSize}")
    List<BookInfo> selectAll(Integer currentPage,Integer pageSize);
    @Select("select count(*) from book_info")
    Integer selectTotal();
    @Insert("insert into book_info(book_name,author,count,price,publish,status) values" +
            "(#{bookName},#{author},#{count},#{price},#{publish},#{status})")
    Integer insertDate(BookInfo bookInfo);

    @Select("select* from book_info where id=#{id}")
    BookInfo selectById(Integer id);

    @Update("update book_info set book_name=#{bookName},author=#{author},count=#{count}," +
            " price=#{price},publish=#{publish},status=#{status} where id=#{id}")
    Integer updateBook(BookInfo bookInfo);

    @Delete("delete from book_info where id=#{id}")
    Integer deleteBook(Integer id);

    @Delete("delete from book_info where id in(#{ids})")
    Integer deleteBooks(List<Integer> ids);
}
